//
//  ControllerManager.m
//  项目三
//
//  Created by rimi on 15/9/28.
//  Copyright (c) 2015年 rimi. All rights reserved.
//

#import "ControllerManager.h"

@interface ControllerManager ()

@property (nonatomic, strong) UINavigationController * rootViewController;

@property (nonatomic, strong) ViewController *viewController;

@property (nonatomic, strong) MainViewController *mainViewController;

@end

@implementation ControllerManager

+ (ControllerManager *)sharedManager {
    static ControllerManager * manager ;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        manager = [[ControllerManager alloc] init];
    });
    return manager;
}

#pragma mark - getter
- (UINavigationController *)rootViewController {
    if (!_rootViewController) {
        _rootViewController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
        _rootViewController.navigationBarHidden = YES;
    }
    return _rootViewController;
}
- (MainViewController *)mainViewController {

    if (!_mainViewController) {
        // 生成tabController所管理的controller数组
        
        _mainViewController = [[MainViewController alloc] init];
    }
    return _mainViewController;
}
- (ViewController *)viewController {

    if (!_viewController) {
        UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.mainViewController];
        navigationController.navigationBarHidden = YES;
        
        _viewController = [[ViewController alloc] initWithMainViewController:navigationController];
    }
    return _viewController;
}
@end
